-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Natasha Vasquez #8
base: main
Are you sure you want to change the base?
Conversation
|
||
def initialize(item_details) | ||
@name = item_details[:name] | ||
@price = item_details[:price] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The interaction pattern asks the price string to be cleaned (remove the $) and converted to a float.
@@ -1,3 +1,10 @@ | |||
class Item | |||
|
|||
attr_reader :name, :price | |||
|
|||
def initialize(item_details) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just item
is probably a nice param name here.
|
||
|
||
attr_reader :name, :vendors | ||
attr_accessor :sorted_item_list |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this variable need to be updated outside of this class? Probably not.
def total_inventory | ||
inventory = {} | ||
vendors.each do |vendor| | ||
vendor.inventory.each do |item, quantity| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice logic in here!
def overstocked_items | ||
overstocked = [] | ||
total_inventory.each do |item, data| | ||
if data[:vendors].length > 1 && data[:quantity] > 50 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great conditional logic!
@inventory.each do |item, quantity| | ||
item_price = item.price.delete('$').to_f | ||
total_revenue += item_price * quantity | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation here! Really great work with this encapsulated class, though.
end | ||
|
||
it 'exists' do | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove whitespace! And pay attention to indentation :)
end | ||
|
||
it 'can return vendor names, items sold at vendors, and vendor revenue' do | ||
@vendor1 = Vendor.new("Rocky Mountain Fresh") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some of this setup could have been included in your beforeach
No description provided.